import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { OpenThrTouter, DelDataButton, AnnexButton, SaveFilesUrl } from '../Common/options'

export const AnnexPerson = async ({ OptionsEvent, oneData, Permission, actionRef, tableName, tableNameList }) => {
    console.log(oneData)
    let dataList = {
        pageSize: 10,
        hideInSearch: true,
        params: { businessUuid: oneData.uuid, OrderField: 'tableName@asc' },
        initialValues: { uuid: oneData.uuid, businessUuid: oneData.uuid },
        get: API_LIST()['getUserBusinessRelations'],
        added: 'posAttachmentDetails',
        options: [
            <OpenThrTouter
                title="添加人员"
                type="primary"
                icon="add"
                modal="SelectModal"
                OptionsEvent={OptionsEvent}
                other={{
                    page: 'AnnexPersonDetails',
                    actionRef,
                    Permission,
                    twoData: oneData,
                }}
            />,
        ],
        columns: [
            {
                title: 'uuid',
                dataIndex: 'uuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            {
                title: 'businessUuid',
                dataIndex: 'businessUuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            {
                dataIndex: 'fullName',
                title: '姓名',
                valueType: 'input',
            },
            {
                dataIndex: 'organizationName',
                title: '组织机构',
                valueType: 'input',
            },
            {
                dataIndex: 'isReport',
                title: '是否上报',
                valueType: 'select',
                valueEnum: { 0: '否', 1: '是' },
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { fileUrl, originalName } = record
                    return [
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url="UserBusinessRelations"
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return dataList
}
